using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;

public partial class DodadiIgrac : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Label3.Text = "";
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/Proekt.mdb;"; //postavuvame "adresa" do bazata
        OleDbConnection conn = new OleDbConnection(conString);

        conn.Open();

        string select = "SELECT IME FROM IGRACI WHERE IME = ?";
        OleDbCommand select_igrac = new OleDbCommand(select, conn);
        select_igrac.Parameters.AddWithValue("?", TextBox1.Text);

        if (!select_igrac.ExecuteReader().HasRows)
        {
            string insert = "INSERT INTO IGRACI(IME) VALUES(?)";
            OleDbCommand insert_igrac = new OleDbCommand(insert, conn);
            insert_igrac.Parameters.AddWithValue("?", TextBox1.Text);
            insert_igrac.ExecuteNonQuery();

            TextBox1.Text = "";
        }
        else
        {
            Label3.Text = "Igrac so toa ime veke postoi vo bazata!!!";
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "";
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Response.Redirect("Admin.aspx");
    }
}
